package com.dynamic.data.permission.rpc;

import com.dynamic.data.permission.config.PermissionProperties;
import com.dynamic.data.permission.model.UserInfoContext;
import com.dynamic.data.permission.common.util.SpringContextUtil;

import javax.servlet.http.HttpServletRequest;
import java.util.*;

public class UserServerRpc {

    private static String userServiceUrl;

    static {
        PermissionProperties permissionProperties = SpringContextUtil.getBean(PermissionProperties.class);
        userServiceUrl = permissionProperties.getUserServiceUrl();
    }

    /**
     * 获取当前用户信息
     */
    public static UserInfoContext currentUser(HttpServletRequest request) {
        String url = userServiceUrl + "/getUserInfo";
        //mock 请求用户服务获取用户信息
        UserInfoContext userInfoContext = new UserInfoContext();
        userInfoContext.setUserId(1000L);
        userInfoContext.setRegisterTime(new Date());
        return userInfoContext;
    }

}
